<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        *{
            padding: 0;
            margin: 0;
        }
        .box{
            margin: 50px;
        }
        .box .title{
            line-height: 80px;
            text-align: center;
        }
        .smallbox{
            width: 90%;
            background-color: white;
            margin-left: 10px;

        }
        .smallbox p{
            text-align: center;
            margin-top: 30px;
            font-weight: bold;
            font-size: 20px;
        }
        .smallbox .block{
            margin: 30px 0;
        }
        .smallbox .block input{
            height: 40px;
            padding-left: 20px;
            border: 1px solid #ccc;
            border-radius: 5px;
            width: 100%;
            outline: none;
            box-sizing: border-box;
        }
        .smallbox .block .btn{
            height: 40px;
            padding-left: 20px;
            border: 1px solid #ccc;
            border-radius: 5px;
            width: 100%;
            outline: none;
            box-sizing: border-box;
            background-color: blue;
            color: white;
            font-size: 16px;
        }
    </style>
</head>
<body>
    <div class="box">
        <h1 class="title">阿里云盘</h1>
        <div class="smallbox">
            <p>注册新账号</p>
            <div class="block">
                <input type="text" placeholder="请输入账号">
            </div>
            <div class="block">
                <input type="password" placeholder="请输入密码">
            </div>
            <div class="block">
                <input type="password" placeholder="确认密码">
            </div>
            <div class="block">
                <button class="btn">注册</button>
            </div>
        </div>
    </div>
</body>
</html>
<script src="./1.ajax.js"></script>
<script>
    var oInputs=document.querySelectorAll('.box .smallbox input')
    var oBtn=document.querySelector('.box .smallbox .btn')

    oBtn.onclick=function(){
        if(oInputs[0].value&&oInputs[1].value ){
            if( /^1[3-9]\d{9}$/.test( oInputs[0].value )&& /^\d{6,}$/.test(oInputs[1].value)){
                ajax('get','https://yantianfeng.com/api/register',{
                    username:oInputs[0].value,
                    password: oInputs[1].value,
                    password: oInputs[2].value,

                },function(data){
                    if (data.code == 200) {
                        alert('登录成功');
                    } else {
                        alert('登录失败');
                    }
                })
                
            }else{
                alert('请输入正确的账号/密码')
            }
        }else{
            alert('账号密码不能为空')
        }
    }
</script>